package cn.gok.work;

class Person {
    private String name;
    private String sex;
    private int age;
    private String isMarried;

    public Person() {
    }

    public Person(String name, String sex, int age, String isMarried) {
        this.name = name;
        this.sex = sex;
        this.age = age;
        this.isMarried = isMarried;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", sex='" + sex + '\'' +
                ", age=" + age +
                ", isMarried='" + isMarried + '\'' +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getIsMarried() {
        return isMarried;
    }

    public void setIsMarried(String isMarried) {
        this.isMarried = isMarried;
    }

    public static boolean marryWith(Person p1, Person p2) {
        return p1.isMarried.equals("否") && p2.isMarried.equals("否") && !(p1.sex.equals(p2.sex))
                && p1.age >= 20 && p2.age >= 19;
    }

    public void study(String school) {
        System.out.println(this.name + "在" + school + "学校学习");
    }
}

public class 作业三 {
    public static void main(String[] args) {
        Person person = new Person("wangwu", "男", 19, "否") {
            @Override
            public void study(String school) {
                System.out.println(getName() + "在" + school + "学校学习了几年");
            }
        };
        Person p1 = new Person("zhangsan", "男", 21, "否");
        Person p2 = new Person("lisi", "女", 20, "否");
        Boolean result = Person.marryWith(p1, p2);
        System.out.println(result);
        person.study("QVTU");
    }
}
